package me.caofeng.pojo;

import me.caofeng.enums.Role;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.Date;

/**
 * Copyright © 2017曹峰. All rights reserved.
 *
 * @Prject: mall
 * @Package: me.caofeng.pojo
 * @Description:
 * @Author: 曹峰 blog.caofeng.me
 * @Date: 2017-06-15 16:41
 * @Version: V1.0
 */
public class User extends Pojo{
    private String uid;

    @NotNull(message = "用户名不能为空")
    @Size(min = 2 ,message = "用户名最小要两个字符")
    private String name;

    @NotNull(message = "密码不能为空")
    @Size(min = 6 ,message = "密码最小长度为6")
    @Pattern(regexp = "^[^\\u4e00-\\u9fa5]+$",message = "密码不能包含中文")
    private String password;

    @NotNull(message = "手机号不能为空")
    @Pattern(regexp = "^((13[0-9])|(14[5|7|9])|(15([0-3]|[5-9]))|(17[0|5|6|7|8|])|(18[0-9]))\\d{8}$" ,
            message = "手机号格式错误")
    private String phone;

    private Role role;

    public User() {
    }

    public User(int id, Date createTime, Date updateTime, int isDelete, String uid, String name, String password, String phone, Role role) {
        super(id, createTime, updateTime, isDelete);
        this.uid = uid;
        this.name = name;
        this.password = password;
        this.phone = phone;
        this.role = role;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }


    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", uid= " + uid +
                ", createTime=" + createTime +
                ", name='" + name + '\'' +
                ", updateTime=" + updateTime +
                ", password='" + password + '\'' +
                ", isDelete=" + isDelete +
                ", phone='" + phone + '\'' +
                ", role=" + role +
                '}';
    }
}
